
import ac = module("utils/commons/array-collection");
	
/**
	* The list of valid concept roles.
	* 
	* @author Xavier Sosnovsky, Anthony Morel
	*/
export class ConceptRole {
		
	/*==============================Fields================================*/
		
	private static _instance:ConceptRole;
		
	private static _roles:ac.ArrayCollection<string>;
		
	/*============================Constants===============================*/
		
	/**
	    * Identifies the {@link Concept} that plays the role of the frequency.
	    */
	public static FREQUENCY:string = "frequency";
	/**
	    * Identifies the {@link Concept} that plays the role of an identifier 
	    * where the identifier is taken from a known system of counts.
	    */
	public static COUNT:string = "count";
	    
	/**
	    * Identifies the {@link Concept} that plays the role of identifying a 
	    * type of measure.
	    */
	public static MEASURE_TYPE:string = "measureType";
	    
	/**
	    * Identifies the {@link Concept} that plays the role of a day/time
	    * identifier in the {@link KeyFamily} which is not related to the time 
	    * of the observation.
	    */
	public static NON_OBS_TIME:string = "nonObsTime";
	    
	/**
	    * Identifies the {@link Concept} that plays the role of an identifier 
	    * which is taken from a known scheme of identifiers.
	    */
	public static IDENTITY:string = "identity";
	    
	/**
	    * Identifies the {@link Concept} that specifies the time of the 
	    * observation of the {@link primaryMeasure}.
	    */
	public static TIME:string = "time";
	    
	/**
	    * Identifies the {@link Concept} that plays the role of the observation 
	    * in a time series.
	    */
	public static PRIMARY_MEASURE:string = "primaryMeasure";
	    
	/**
	    * Identifies the {@link Concept} that plays the role of the subject to 
	    * whom the data refers (e.g.: the reporting agent for primary 
	    * reporting).
	    */
	public static ENTITY:string = "entity";
	    
	/**
	    * Identifies the {@link Concept} that plays the role of the subject to 
	    * whom the data refers (e.g.: the reporting agent for primary 
	    * reporting).
	    */
	public static TIME_FORMAT:string = "timeFormat";
	    
	/*===========================Constructor==============================*/
		
	constructor(enforcer:SingletonEnforcer) {
	}
	    
	/*==========================Public methods============================*/
	    
	/**
	    * Whether the supplied conceptRole is in the list of valid SDMX concept 
	    * roles.
	    * 
	    * @return true if the supplied conceptRole is in the list of valid SDMX 
	    * concept roles, false otherwise.
	    */ 
	public static contains(conceptRole:string):bool {
	    return this.createConceptRoleList().contains(conceptRole);
	}
	    
	/*=========================Private methods============================*/
	    
	private static createConceptRoleList():ac.ArrayCollection<string> {
	    if (null == this._instance) {
	    	this._instance = new ConceptRole(new SingletonEnforcer());
            this._roles = new ac.ArrayCollection<string>();
            this._roles.addItem(this.FREQUENCY);
            this._roles.addItem(this.COUNT);
            this._roles.addItem(this.MEASURE_TYPE);
            this._roles.addItem(this.NON_OBS_.TIME);
            this._roles.addItem(this.ID.ENTITY);
            this._roles.addItem(this.TIME);
            this._roles.addItem(this.PRIMARY_MEASURE);		    		    		    		    
            this._roles.addItem(this.ENTITY);
            this._roles.addItem(this.TIME_FORMAT);
		}
		return this._roles;
	}
}

export class SingletonEnforcer {
}